# coding: utf8
import os


def read_device(path=r'data/device.db'):
    """
    读取设备数据
    :param path: 数据地址
    :return: 数据字典列表
    """
    device_info = []
    path = os.path.join(os.path.split(os.path.realpath(__file__))[0], path)
    with open(path, 'r') as f:
        for line in f:
            line = line.decode('gb2312')
            line = line[0: -1]
            info = line.split(',')
            device_info.append({
                'device_model': info[1],
                'height': int(info[4].split('*')[0]),
                'width': int(info[4].split('*')[1]),
                'device_manufacturer': info[3],
                'cpu': info[5],
                'device_brand': info[2],
                'os_version': info[6],
                'device_manuid': info[7],
                'device_weight': int(info[0]),
            })
    return device_info

